<template>
    <div id="dialog-container">
        <el-dialog v-dialogDrag 
            title="万能量具历史记录卡" append-to-body
            :visible.sync="dialogVisible" @close="$emit('update:show', false)" :before-close="handleClose" :show="show"
            :close-on-click-modal="false" width="760px">
            <el-form :model="form" :inline="true" size="small" label-width="110px">
                <el-row type="flex" justify="center">
                    <h2 style="margin-bottom: 25px;">万能量具历史记录卡</h2>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="企业名称：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="存放地点：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="检定地点：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="器具名称：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="测量范围：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="刻度值：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="生产厂家：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="使用部门：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="附件：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="使用前级数：">
                            <el-input v-model="form.name"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="统一编号：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检定周期：">
                            <el-input v-model="form.name" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-tabs type="border-card">
                    <el-tab-pane label="修理记录">
                        <el-col :span="14">
                            <el-form-item label="修理日期：">
                                <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="修理摘要：">
                                <el-input v-model="form.name" type="textarea" :row="2" style="width: 482px;"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-tab-pane>
                    <el-tab-pane label="国家检定结果">
                        <el-col :span="14">
                            <el-form-item label="检定日期：">
                                <el-date-picker v-model="form.date" type="date" placeholder="选择日期"></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="14">
                            <el-form-item label="检定结果：">
                                <el-select v-model="form.departmentVal" placeholder="请选择" style="width: 200px;">
                                    <el-option v-for="item in form.department"
                                        :key="item.value" :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-tab-pane>
                    <el-tab-pane label="周期检定结果">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="检定日期：" label-width="160px">
                                    <el-date-picker v-model="form.date" type="date" placeholder="选择日期" style="width: 160px;"></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="受检部位：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="校正规或量爪的尺寸：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="结论等级技术：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="下次检定日期：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="检定人：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="检定结果：" label-width="160px">
                                    <el-input v-model="form.name" style="width: 160px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="附件：" label-width="160px">
                                    <el-upload
                                        class="upload-demo"
                                        action="https://jsonplaceholder.typicode.com/posts/"
                                        :on-preview="handlePreview"
                                        :on-remove="handleRemove"
                                        :before-remove="beforeRemove"
                                        multiple
                                        :limit="3"
                                        :on-exceed="handleExceed"
                                        :file-list="fileList">
                                        <el-button size="small" type="primary">点击上传</el-button>
                                        <span slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</span>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-tab-pane>
                </el-tabs>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import AddTest from 'dialog/test-manage/week-test-plan/add-wait-test';
    export default {
        components: {
            'add-test': AddTest
        },
        data() {
            return {
                dialogVisible: this.show,
                form: {
                    name: '',
                    data: ''
                },
                fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}]
            }
        },
        props: {
            show: {
                type: Boolean,
                default: false
            }
        },
        watch: {
            show() {
                this.dialogVisible = this.show;
            }
        },
        methods: {
            handleClose() {
                this.dialogVisible = false;
            },
            // 文件上传
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            handleExceed(files, fileList) {
                this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${ file.name }？`);
            }
        }
    }
</script>

<style scoped>
 .el-date-editor.el-input{
     width: 200px;
 }
</style>

